﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ClassLibrary2.Model;

namespace ClassLibrary2.Services
{
    public static class Customers
    {
        public static IList<Model.ViewModelCustomers> GetListCustomer()
        {
            using (var db = new VLXDKH_QLKEntities())
            {
                var c_ret = db.CUSTOMERS.Select(x => new ViewModelCustomers
                {
                    ID_CUS = x.ID_CUS,
                    NAME_CUS = x.NAME_CUS,
                }).ToList();
                return c_ret;
            }

        }
        public static void InsertCustomer(ViewModelCustomers customer)
        {
            using (var db = new VLXDKH_QLKEntities())
            {
                CUSTOMER c = new CUSTOMER();
                c.NAME_CUS = customer.NAME_CUS;

                db.CUSTOMERS.Add(c);
                db.SaveChanges();
            }

        }

    }
}
